package com.jr.controller;

import com.jr.pojo.TopListAndBlogText;
import com.jr.service.TopListService;
import com.jr.util.ResultObject;
import com.sun.scenario.effect.impl.sw.java.JSWBlend_SRC_OUTPeer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;

@RestController /*替换@RestController=@Controller + @ResponseBody*/
@RequestMapping("/Top/")
public class TopListController {
    @Autowired
    private TopListService topListMapperService;
    @Autowired
    private ResultObject result;
    @RequestMapping("showTop")
    public ArrayList<TopListAndBlogText> showTop(TopListAndBlogText topListAndBlogText){
        result.setStatus(400);
        int i = topListMapperService.showTop(topListAndBlogText).size();
        ArrayList<TopListAndBlogText> blogTextArrayList = new ArrayList<>();
        for (int j=0;j<i;j++){
            TopListAndBlogText topListAndBlogText1 = topListMapperService.showTop(topListAndBlogText).get(j);
            blogTextArrayList.add(topListAndBlogText1);
        }
        return blogTextArrayList;
    }
}
